package com.chixing.service.impl;

import com.chixing.mapper.FlowMapper;
import com.chixing.pojo.Flow;
import com.chixing.pojo.FlowExample;
import com.chixing.service.FlowService;
import com.chixing.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author dwe
 * @date 2021-11-03 20:08
 */
@Service
public class FlowServiceImpl implements FlowService {
    @Autowired
    private FlowMapper flowMapper;

    @Override
    public ServerResponse save(Flow flow) {
       int rows =  flowMapper.insert(flow);
       if(rows >0)
        return ServerResponse.saveSuccess(rows);
       return ServerResponse.saveFail(null);
    }

    @Override
    public ServerResponse getByOrderId(Integer orderId) {
        FlowExample example = new FlowExample();
        example.createCriteria().andOrdIdEqualTo(orderId);
        Flow flow = (Flow)flowMapper.selectByExample(example).get(0);
        return ServerResponse.getSuccess(flow);
    }
}
